<div data-ng-controller="contractDocsCtrl">
    <!-- 合同名称-->
    <div class="table-header clearfix ng-scope">
        <span class="fl lh30 f14">{{contractBaseInfo.contract_code}}</span>
    </div>

    <form class="form-horizontal">
        <!-- 上传附件-->
        <div class="mtb20 ml25 clearfix">
            <div>
                <div id="fileupload" class="fileinput-button btn" >
                    <span class="f13">上传附件</span>
                    <input type="file" name="file" accept=".xls,.xlsx,.doc,.docx,.pdf,.msg" >
                </div>
                <div class="c-red f13" style="clear:both;display: none;" id="fileupload_tip">上传中……</div>
                <div class="c-red f13" style="clear:both;display: none" id="fileupload_error">上传失败</div>
                <input type="hidden" id="fileupload_url" value="{{contractFiles}}"/>

                <div>
                    <div style="height: 28px;display: inline-block;margin-right: 20px"
                         ng-repeat="file in contractFiles" ng-if="file.__type != 'delete'">
                        <a target="_blank" href="{{file.document_path}}">{{file.document_name}}</a>
                        <a class="glyphicon glyphicon-trash" title="删除附件" href="javascript: void(0)"
                           ng-click="delAttachment(file,$index)" ></a>
                    </div>
                </div>

            </div>
        </div>

        <!-- 新增文档-->
        <div class="mt20 clearfix ng-scope ml25" ng-if="contractBaseInfo.is_cancelled == 0">
            <button class="btn" href="javascript:void(0)" ng-click="addDocument()">新增合同文档</button>
        </div>

        <!-- 合同文档表格-->
        <div class="table-wrap mt10 ml25" style="min-height: 200px;overflow: visible">

            <table width="100%" class="valign-t">
                <!-- 表头-->
                <thead>
                <tr>
                    <th style="width: 35px;text-align: center;">序号</th>
                    <th style="width: 130px;">文件类型</th>
                    <th style="width: 130px;">纸质合同归档日期</th>
                    <th style="width: 180px;">纸质合同存放位置</th>
                    <th style="width: 130px;">纸质合同类型</th>
                    <th>保管人</th>
                    <th style="width: 150px;">所属文件夹名称</th>
                    <th style="width: 80px;">操作</th>
                </tr>
                </thead>

                <!-- 表格内容-->
                <tbody>
                <tr ng-repeat="record in contractDocsInfo" ng-if="record.__type != 'delete'"
                    style="line-height: 35px;">
                    <td style="text-align: center"><p ng-bind="$index + 1"></p></td>
                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.document_ext_name"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input name="document_ext_name" select2 ng-model="record.document_ext_name"
                                   select2-model="record.ddl2DocumentExtName"
                                   config="ddlConfigDocumentExtName" type="text" placeholder="文件类型"
                                   class="form-control idDocumentExtName">
                        </p>
                    </td>
                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.pigeonhole_date"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input type="text" name="pigeonhole_date" class="form-control"
                                   ng-model="record.pigeonhole_date" ui-date
                                   format="yyyy-MM-dd" placeholder="纸质合同归档日期">
                        </p>
                    </td>
                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.document_path"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input name="document_path" type="text" ng-model="record.document_path"
                                   class="form-control"
                                   placeholder="纸质合同存放位置">
                        </p>
                    </td>
                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.contract_document_type"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input name="contract_document_type" select2 ng-model="record.contract_document_type"
                                   select2-model="record.ddl2ContractDocumentType" data="record"
                                   config="ddlConfigContractDocumentType" type="text" placeholder="纸质合同类型"
                                   class="form-control idContractDocumentType">
                        </p>
                    </td>
                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.keeper_name"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input name="keeper" select2 ng-model="record.keeper"
                                   select2-model="record.ddl2Keeper" data="record"
                                   config="ddlConfigKeeper" type="text" placeholder="保管人"
                                   class="form-control idKeeper">
                        </p>
                    </td>
                    <td>
                        <p ng-if="(record.editMode || 0) == 0" ng-bind="record.document_dir"></p>

                        <p ng-if="(record.editMode || 0) != 0">
                            <input name="document_dir" type="text" ng-model="record.document_dir"
                                   class="form-control"
                                   placeholder="所属文件夹名称">
                        </p>
                    </td>
                    <td>
                        <div row-toolbar min-buttons-show="3" ng-if="contractBaseInfo.is_cancelled == 0">
                            <a ng-if="(record.editMode || 0)  == 0" href="javascript:void(0)"
                               title="修改合同信息"
                               ng-click="editContractDocument(record, $index)">修改</a>
                            <a ng-if="(record.editMode || 0)  == 0" href="javascript:void(0)"
                               ng-click="delContractDocument(record)"
                               title="删除合同信息">删除</a>

                            <a ng-if="(record.editMode || 0)  != 0" href="javascript:void(0)"
                               title="保存合同信息"
                               ng-click="saveContractDocument(record)">确定</a>
                            <a ng-if="(record.editMode || 0)  != 0" href="javascript:void(0)"
                               title="取消修改合同信息"
                               ng-click="cancelContractDocument(record, $index)">取消</a>
                        </div>
                    </td>
                </tr>
                </tbody>
            </table>
            <div class="no-data" ng-if="contractDocsInfo.length == 0"><span>暂无数据</span></div>
        </div>

        <!-- 保存-->
        <div class="form-group" ng-if="contractBaseInfo.is_cancelled == 0">
            <div class="ml35 mt15">
                <button type="button" ng-click="save()" class="btn btn-default" ng-disabled="saveEnabled()">保存</button>
            </div>
        </div>
    </form>
</div>